#!/bin/bash

# 设置变量
TARBALL="nomachine-enterprise-desktop_8.12.12_4_x86_64.tar.gz"
DEST_DIR="/usr/NX"

# 安装网络工具
sudo apt install net-tools

# 安装性能分析工具
sudo apt-get  install htop


# 下载nomachine
wget https://download.nomachine.com/packages/8.12-PRODUCTION/Linux/nomachine-enterprise-desktop_8.12.12_4_x86_64.tar.gz

# 检查tarball是否存在
if [ ! -f "$TARBALL" ]; then
    echo "Error: $TARBALL does not exist."
    exit 1
fi

# 复制tarball到/usr目录
sudo cp -p "$TARBALL" /usr

# 切换到/usr目录
cd /usr

# 解压tarball
sudo tar zxf "$TARBALL" -C "$DEST_DIR" --strip-components=1

# 安装NX服务器
if [ -f "$DEST_DIR/nxserver" ]; then
    sudo "$DEST_DIR/nxserver" --install
else
    echo "Error: nxserver not found in $DEST_DIR."
    exit 1
fi

# 安装sshd服务
sudo apt-get install openssh-server

# 开启ssh服务
sudo systemctl start sshd

# 关闭图像化界面
systemctl set-default multi-user.target

# 开启图像化界面
# systemctl set-default graphical.target

# 安装vscode
sudo snap install --classic code

# 安装ros2
# wget http://fishros.com/install -O fishros && . fishros

# 安装雷达驱动
# cd ~
# sudo apt install cmake
# git clone https://github.com/Livox-SDK/Livox-SDK2.git
# cd ./Livox-SDK2/
# mkdir build
# cd build
# cmake .. && make -j
# sudo make install
